package com.zoe.app.config;

import com.zoe.app.filter.DynamicFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author Zoe.Zhang
 * @date 2021/10/10
 * @description
 */
@Component
public class DynamicFilterRegisterBeanConfig {
    @Autowired
    private DynamicFilter dynamicFilter;

    @Bean
    FilterRegistrationBean<DynamicFilter> filterFilterRegistrationBean() {
        FilterRegistrationBean<DynamicFilter> dynamicFilterFilterRegistrationBean = new FilterRegistrationBean<>();
        dynamicFilterFilterRegistrationBean.setFilter(dynamicFilter);
        dynamicFilterFilterRegistrationBean.setEnabled(true);
        dynamicFilterFilterRegistrationBean.addUrlPatterns("/*");
        return dynamicFilterFilterRegistrationBean;
    }
}
